package com.sbc.distributed_id.toolkit;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;

/**
 * @description: 分布式雪花 ID 生成器
 * @author: songbaicheng
 * @create: 2024-03-21 22:25
 **/
public final class SnowflakeIdUtil {

    private static final long dataCenterId = 1L; // 数据中心ID
    private static final long workerId = 1L; // 工作机器ID
    private static final Snowflake snowflake = IdUtil.getSnowflake(workerId, dataCenterId);

    /**
     * 获取雪花算法下一个 ID
     * @return 雪花 ID
     */
    public static Long nextId() {
        return snowflake.nextId();
    }
}
